Skip to content

Conversation

@lishaduck
Copy link
Contributor

@lishaduck lishaduck commented Mar 1, 2025

I'd like being able to use my computer while I have Freezed open. On my 816GB Ram potato computer of an M14, opening the Freezed folder slows it down to a crawl. This fixes that.

Summary by CodeRabbit

  • Chores

    • Added a workspace setup, updated SDK constraints, switched many packages to published versions, standardized ignores, removed local dependency overrides, and renamed benchmark project.
  • Tests

    • Expanded CI matrix (adds master), centralized working directory for CI steps, simplified dependency install and test detection, and made codegen/format steps more consistent and resilient.
  • Lint

    • Tightened analysis to treat infos as fatal, updated diagnostics text, and adjusted example lint run scope.
  • Build/Tooling

    • Excluded examples from build sources, included nested tests, and bumped tooling/dependency versions.

@coderabbitai
Copy link

coderabbitai bot commented Mar 1, 2025

Walkthrough

Adds a Dart workspace, updates CI workflow and build settings, adjusts many pubspecs/overrides and .gitignore rules, adds/updates Freezed-generated example files (and removes one), tweaks lint messages, and reorganizes dependency overrides and build.yaml include/exclude patterns.

Changes

Cohort / File(s) Summary
CI workflow
\.github/workflows/build.yml
Expanded matrix (adds benchmarks and packages/freezed_lint/example, adds master channel), introduced defaults.run.working-directory, changed cache condition, consolidated dependency install, simplified format/generate/analyze/test steps, removed example-folder removal step, added continue-on-error for generator skip, narrowed lint golden run.
Workspace root & overrides
pubspec.yaml, pubspec_overrides.yaml
Added workspace freezed_workspace with members, introduced resolution: workspace, reorganized/reordered dependency overrides and bumped/added overrides (frontend_server_client, matcher, watcher, etc.).
Package pubspecs & resolutions
benchmarks/pubspec.yaml, packages/freezed/pubspec.yaml, packages/freezed_annotation/pubspec.yaml, packages/freezed/example/pubspec.yaml, packages/freezed_lint/pubspec.yaml, packages/freezed_lint/example/pubspec.yaml, packages/freezed_lint/pubspec_overrides.yaml
Raised SDK constraints, added resolution: workspace, replaced local path deps with published versions or bumped versions, removed local dependency_overrides from examples, adjusted analyzer_plugin/freezed_annotation versions.
Build config
packages/freezed/build.yaml
Added targets.$default.sources.exclude: ['example/*'], removed example exclude from generate_for.exclude, and expanded generate_for.include to include test/**/*.
.gitignore changes
\.gitignore, benchmarks/.gitignore, packages/freezed/.gitignore, packages/freezed/example/.gitignore, packages/freezed_annotation/.gitignore, packages/freezed_lint/.gitignore
Normalized ignore patterns (removed some /.dart_tool and pubspec.lock ignores), stopped ignoring certain generated files in examples, added trailing newline at root.
Benchmarks formatting tweaks
benchmarks/lib/src/copy_with.dart, benchmarks/lib/src/copy_with.freezed.dart, benchmarks/lib/src/equal.freezed.dart
Minor formatting/header directive changes; no behavioral changes.
Generated example files (added)
packages/freezed/example/lib/diagnosticable.freezed.dart, packages/freezed/example/lib/equals.freezed.dart, packages/freezed/example/lib/main.freezed.dart, packages/freezed/example/lib/main.g.dart, packages/freezed/example/lib/non_diagnosticable.freezed.dart, packages/freezed/example/lib/time_slot.freezed.dart
New Freezed-generated models, unions, copyWith, diagnostics, and JSON (de)serialization for the example package.
Generated example file (removed)
packages/freezed_lint/example/lib/missing_mixin.freezed.dart
Deleted previously generated Freezed file and all its declarations (mixins/types/copyWith implementations).
Lint message text tweaks
packages/freezed_lint/lib/src/missing_mixin.dart, packages/freezed_lint/lib/src/missing_private_empty_ctor.dart
Small textual edits to diagnostic/correction message strings (wording/spacing).
Example analysis options
packages/freezed_lint/example/analysis_options.yaml
Added expected analyzer error codes to ignore (uri_does_not_exist, redirect_to_non_class, mixin_of_non_class, unused_element).
Git attributes
\.gitattributes
Marks Dart files matching **/*.*.dart as linguist-generated=true.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor GH as GitHub Actions
  participant M as Matrix(package × channel)
  participant SDK as Flutter/Dart SDK
  participant P as Package (working-directory = matrix.package)

  GH->>M: start job per matrix entry
  M->>SDK: setup SDK (channel)
  M->>P: flutter pub ${{ matrix.dependencies }}
  alt package on stable
    M->>P: flutter format --set-exit-if-changed
  end
  alt package != packages/freezed_lint/example
    M->>P: dart run build_runner build --delete-conflicting-outputs
  else
    note right of M: generator skipped for freezed_lint/example\n(step allowed to continue)
  end
  M->>P: flutter analyze --fatal-infos
  alt pubspec contains flutter_test
    M->>P: flutter test
  else pubspec contains test
    M->>P: dart test
  end
  alt package == packages/freezed_lint/example
    M->>P: dart run custom_lint --fatal-infos
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • rrousselGit

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The current pull request description addresses personal performance concerns and does not describe the actual modifications made, which involve adding workspace configurations and updating multiple project files for Pub workspaces. Rewrite the description to summarize the introduction of the root pubspec.yaml for workspace configuration, dependency updates, and relevant file changes that implement Pub workspaces.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title “Pub Workspaces” succinctly captures the primary purpose of this pull request, which is to introduce and configure Dart Pub workspaces in the repository, offering clear and focused context for reviewers.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

I hop through YAML and generated trees,
Workspace roots sprout with tidy ease.
CI branches out, examples grow bright,
Lints whisper fixes in the quiet night.
Carrots for builds — a crunchy, happy bite. 🥕

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lishaduck
Copy link
Contributor Author

Huh. Can't repro the formatting issue on master.

Comment on lines -1 to -3
*.freezed.dart
*.g.dart

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change gitignores?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while, I honestly don't remember.

Copy link
Contributor Author

@lishaduck lishaduck Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I remember now. This was in the example, if the code wasn't checked in the order that CI ran tripped something up. c5d83a7

Probably not strictly needed anymore, but feels like a nice QoL improvement?

@rrousselGit rrousselGit marked this pull request as ready for review July 1, 2025 08:16
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (5)
packages/freezed_lint/lib/src/missing_private_empty_ctor.dart (1)

14-15: Fix grammar & remove superfluous comma in diagnostic message

The concatenated string currently reads
'Freezed classes containing methods, fields or accessors, requires a {0}'.
Grammatically this should be “require”, and the comma after accessors is unnecessary.

-        'Freezed classes containing methods, fields or accessors, '
-        'requires a {0}',
+        'Freezed classes containing methods, fields or accessors require a {0}',
packages/freezed/example/lib/main.freezed.dart (1)

1-13: Same formatting directive conflict

benchmarks/lib/src/copy_with.freezed.dart (1)

1-13: Same formatting directive conflict

packages/freezed/example/lib/diagnosticable.freezed.dart (1)

1-13: Same formatting directive conflict

packages/freezed/example/lib/non_diagnosticable.freezed.dart (1)

1-1: Remove dart format width directive (same issue as in the other file).

🧹 Nitpick comments (15)
packages/freezed_lint/pubspec.yaml (1)

10-10: Minor formatting nit

Consider inserting a blank line before resolution: for readability and to match the style used in other pubspecs.

   sdk: ">=3.5.0 <4.0.0"
+
 resolution: workspace
packages/freezed_lint/lib/src/missing_mixin.dart (1)

11-11: Grammar tweak in diagnostic message

“mix in” is the verb form; the current text reads a little awkward.

-    problemMessage: 'Freezed class should mixin {0}',
+    problemMessage: 'Freezed class should mix in {0}',
pubspec_overrides.yaml (1)

6-18: Keep overrides temporary & monitor for upstream releases

Multiple overrides (e.g. frontend_server_client, matcher, quiver) are bumping versions beyond what build_runner currently requires.
That’s fine locally, but remember to drop these overrides once upstream packages publish compatible releases; long-lived overrides hide real dependency conflicts.

Consider adding a TODO with a tracking issue to ensure cleanup.

packages/freezed_lint/.gitignore (1)

1-3: Re-consider ignoring .dart_tool/ and pubspec.lock at the package level

Removing those two entries means they will be committed unless the root‐level .gitignore still excludes them.
Both directories are generated artefacts and rarely belong in source control. Accidentally adding them clutters diffs, breaks reproducible builds, and can leak local-machine paths.

 .packages
+/.dart_tool
 pubspec.lock
 custom_lint.log

Please verify that the root .gitignore (or workspace rules) already covers them; otherwise add them back here.

packages/freezed_lint/example/pubspec.yaml (1)

2-5: Pin versions instead of any to keep example builds deterministic

All runtime/dev dependencies are declared as any. In a workspace this means the exact versions float with the latest that satisfy transitive constraints, which can lead to:

  • irreproducible CI results over time,
  • breakages when a dependency publishes a breaking change under a new major version,
  • noisy diffs in pubspec.lock that hamper bisects.

Even for examples it is common to use caret-ranges (^) or >= < constraints to document the versions known to compile.

Consider:

-  freezed_annotation: any
+  freezed_annotation: ^2.4.1

(and similar for the other four dev-dependencies).

If you prefer floating versions locally, you can still lock them in CI with --no-pub caching or pub downgrade.

packages/freezed_lint/example/analysis_options.yaml (1)

11-18: Suppressing four additional analyzer errors may hide real regressions

Ignoring uri_does_not_exist, redirect_to_non_class, mixin_of_non_class, and unused_element project-wide is quite broad.
Unless these diagnostics are intentionally triggered by the example (e.g., to demonstrate a lint), they risk masking genuine mistakes as the code evolves.

If the ignores are required for specific files, prefer file-scoped directives:

// ignore_for_file: uri_does_not_exist, redirect_to_non_class

That keeps the global configuration stricter and protects other sources.

Please double-check whether the new ignores are strictly necessary.

packages/freezed/example/lib/time_slot.dart (1)

8-11: Keep trailing comma to stabilise formatter & diffs

Formatting the factory parameters on a single line without a trailing comma will reflow again whenever an import line length changes.
Adding a trailing comma lets dart format consistently break the args onto multiple lines, reducing future churn.

-factory TimeSlot({TimeOfDay? start, TimeOfDay? end}) = _TimeSlot;
+factory TimeSlot({
+  TimeOfDay? start,
+  TimeOfDay? end,
+}) = _TimeSlot;
benchmarks/lib/src/copy_with.dart (1)

13-15: Same trailing-comma nit for constructor

For consistency with the rest of the file and to avoid formatter flip-flops:

-factory ModelWrapper({required Model model}) = _ModelWrapper;
+factory ModelWrapper({
+  required Model model,
+}) = _ModelWrapper;
packages/freezed/example/pubspec.yaml (1)

14-18: Pin build_runner for reproducible builds

build_runner is still un-versioned. Without a constraint, every pub get may fetch a different minor/patch release – unexpected breakages do happen.

   build_runner:
+    ^2.4.9
packages/freezed/example/lib/main.dart (3)

54-59: Reduce duplicate sample code

Two consecutive switch examples test the same unionExample and print the same constant. Collapsing them keeps the example concise:

-  print(switch (unionExample) {
-    Loading _ => 'loading',
-    // voluntarily didn't handle error/complex cases
-    _ => 42,
-  }); // 42

64-70: Second switch already covers all cases

With the first switch preserved, this one adds no extra showcase value. Consider deleting or replacing it with a different example (e.g. pattern-matching on Union.error).


82-84: Minor readability nit

Multi-line print is harder to scan than an interpolated one-liner:

-  print(
-    const Union.error('Failed to fetch'),
-  ); // Union.error(message: Failed to fetch)
+  print(const Union.error('Failed to fetch')); // Union.error(message: Failed to fetch)
benchmarks/pubspec.yaml (1)

14-18: Same build_runner pinning advice

   build_runner:
+    ^2.4.9

Keeps benchmark runs reproducible.

packages/freezed/example/lib/equals.freezed.dart (1)

1-13: Formatting directive conflicts in generated code

The file has // dart format width=80 at line 1 but then // dart format off at line 13, which explains the poor formatting throughout the file. Generated code should either be properly formatted or consistently indicate that formatting is disabled.

Consider updating the code generator to either:

  1. Remove the format width directive if formatting will be disabled
  2. Generate properly formatted code and remove the format-off directive
  3. Add a comment explaining why formatting is disabled for generated files
benchmarks/lib/src/equal.freezed.dart (1)

1-1: Consider removing the dart format width directive from generated code.

The dart format width=80 directive at the top of a generated file is unusual and could cause issues if the code generator doesn't consistently apply this formatting width. Generated files typically shouldn't include formatting directives as they should be controlled by the generator configuration.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7119cac and 63f3366.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (35)
  • .github/workflows/build.yml (2 hunks)
  • .gitignore (1 hunks)
  • benchmarks/.gitignore (0 hunks)
  • benchmarks/lib/src/copy_with.dart (1 hunks)
  • benchmarks/lib/src/copy_with.freezed.dart (2 hunks)
  • benchmarks/lib/src/equal.freezed.dart (2 hunks)
  • benchmarks/pubspec.yaml (1 hunks)
  • packages/freezed/.gitignore (0 hunks)
  • packages/freezed/example/.gitignore (0 hunks)
  • packages/freezed/example/lib/diagnosticable.freezed.dart (1 hunks)
  • packages/freezed/example/lib/equals.freezed.dart (1 hunks)
  • packages/freezed/example/lib/main.dart (2 hunks)
  • packages/freezed/example/lib/main.freezed.dart (1 hunks)
  • packages/freezed/example/lib/main.g.dart (1 hunks)
  • packages/freezed/example/lib/non_diagnosticable.freezed.dart (1 hunks)
  • packages/freezed/example/lib/time_slot.dart (1 hunks)
  • packages/freezed/example/lib/time_slot.freezed.dart (1 hunks)
  • packages/freezed/example/pubspec.yaml (1 hunks)
  • packages/freezed/example/test/diagnosticable_test.dart (1 hunks)
  • packages/freezed/example/test/json_test.dart (1 hunks)
  • packages/freezed/lib/src/templates/concrete_template.dart (0 hunks)
  • packages/freezed/pubspec.yaml (3 hunks)
  • packages/freezed/pubspec_overrides.yaml (0 hunks)
  • packages/freezed_annotation/.gitignore (0 hunks)
  • packages/freezed_annotation/pubspec.yaml (1 hunks)
  • packages/freezed_lint/.gitignore (1 hunks)
  • packages/freezed_lint/example/analysis_options.yaml (1 hunks)
  • packages/freezed_lint/example/lib/missing_mixin.freezed.dart (0 hunks)
  • packages/freezed_lint/example/pubspec.yaml (1 hunks)
  • packages/freezed_lint/lib/src/missing_mixin.dart (1 hunks)
  • packages/freezed_lint/lib/src/missing_private_empty_ctor.dart (1 hunks)
  • packages/freezed_lint/pubspec.yaml (1 hunks)
  • packages/freezed_lint/pubspec_overrides.yaml (0 hunks)
  • pubspec.yaml (1 hunks)
  • pubspec_overrides.yaml (1 hunks)
💤 Files with no reviewable changes (8)
  • benchmarks/.gitignore
  • packages/freezed_annotation/.gitignore
  • packages/freezed/example/.gitignore
  • packages/freezed/.gitignore
  • packages/freezed_lint/pubspec_overrides.yaml
  • packages/freezed/pubspec_overrides.yaml
  • packages/freezed/lib/src/templates/concrete_template.dart
  • packages/freezed_lint/example/lib/missing_mixin.freezed.dart
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
packages/freezed_lint/pubspec.yaml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
packages/freezed_annotation/pubspec.yaml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
packages/freezed_lint/lib/src/missing_private_empty_ctor.dart (1)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
packages/freezed_lint/lib/src/missing_mixin.dart (1)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
packages/freezed_lint/.gitignore (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
packages/freezed/pubspec.yaml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
packages/freezed_lint/example/analysis_options.yaml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
packages/freezed_lint/example/pubspec.yaml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
pubspec.yaml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
packages/freezed/example/pubspec.yaml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
benchmarks/pubspec.yaml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
pubspec_overrides.yaml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
.github/workflows/build.yml (2)
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version upgrade in freezed_lint is blocked by invertase/dart_custom_lint#300 which handles the broader upgrade of analyzer, analyzer_plugin, and source_gen dependencies in custom_lint.
🔇 Additional comments (19)
.gitignore (1)

1-1: 👍 .dart_tool now correctly ignored

Adding the .dart_tool directory to the root ignore list prevents thousands of transient build artefacts from polluting the repo and is consistent with the new workspace layout.

packages/freezed/pubspec.yaml (2)

11-11: Workspace flag added – good move

The resolution: workspace key is required for the new pub workspaces feature and is correctly placed at top level.


21-21: Confirm json_annotation 4.9.x is compatible with json_serializable 6.3.2

The generator’s minimum required json_annotation version can drift; older json_serializable releases occasionally pin lower ranges. Please run dart pub get to ensure there is no version-solve conflict, and bump json_serializable if necessary.

packages/freezed_annotation/pubspec.yaml (2)

10-12: SDK floor raised & workspace enabled – LGTM

The bump to >=3.5.0 and the workspace resolution flag align this package with the rest of the mono-repo.


15-15: Dependency consistency check

json_annotation: ^4.9.0 matches the version used by freezed; good. Ensure downstream consumers that import only freezed_annotation will still resolve a compatible version when not using the workspace (e.g., when published).

pubspec.yaml (2)

3-4: Confirm SDK upper-bound alignment across workspace packages

The root workspace pins the SDK with ^3.7.0.
Please double-check each child package’s pubspec.yaml so none of them declare an upper-bound lower than 3.7.0; otherwise pub get will fail.

No code change needed if already consistent.


6-12: LGTM – workspace list looks correct

Directories are explicitly enumerated and match the repository layout.
Nothing to add here.

packages/freezed/example/test/diagnosticable_test.dart (1)

12-12: Assertion simplification is fine

The single-line expect keeps the test readable and behaviour unchanged.

packages/freezed/example/test/json_test.dart (2)

6-13: Stylistic change only – no issues

Inline map literals make the assertion more concise. 👍


18-18: Likewise, deserialization assertion unchanged

No functional impact; test remains correct.

packages/freezed/example/pubspec.yaml (1)

5-7: Workspace declaration looks good

resolution: workspace is correctly placed at the root level and the SDK floor is lifted to 3.7 – matches the rest of the PR.

packages/freezed/example/lib/main.dart (1)

24-28: Constructor re-formatting only – LGTM
Purely cosmetic change, no behaviour impact.

packages/freezed/example/lib/main.g.dart (1)

1-50: Generated file – skipping manual review

benchmarks/pubspec.yaml (1)

4-7: Workspace alignment acknowledged

Environment bump and workspace flag match the example package – good.

packages/freezed/example/lib/time_slot.freezed.dart (1)

1-146: Generated code – no manual issues detected

.github/workflows/build.yml (2)

50-53: Why exclude format checks for the example package?

Excluding packages/freezed/example from format checks seems counterintuitive. Example code should maintain the same formatting standards as the rest of the codebase to provide good examples for users.

Is there a specific reason for this exclusion? If it's due to generated files, consider using more granular exclusions or ensuring the code generator produces properly formatted output.


35-37: Good workflow improvements!

The following changes improve the CI workflow:

  • Setting a global working directory reduces repetition
  • Simplified dependency installation and code generation steps
  • Using flutter analyze --fatal-infos ensures informational issues are caught
  • Improved test detection logic properly handles different test frameworks
  • Appropriate scoping of lint golden tests

Also applies to: 47-48, 56-57, 60-60, 64-68, 71-72

benchmarks/lib/src/equal.freezed.dart (1)

86-89: Good immutability pattern implementation.

The use of EqualUnmodifiableListView to wrap the list ensures that the list cannot be modified externally, which is a good practice for immutable data classes.

packages/freezed/example/lib/non_diagnosticable.freezed.dart (1)

1-1037: Good addition of comprehensive freezed examples.

This generated file provides excellent examples of various freezed patterns including generic classes, mixins, multiple constructors, and different interface implementations. Adding these generated files to version control (as mentioned in the PR context) helps with workspace performance by avoiding regeneration on every build.

@rrousselGit rrousselGit marked this pull request as draft July 1, 2025 08:48
@lishaduck lishaduck marked this pull request as ready for review September 3, 2025 04:51
@lishaduck
Copy link
Contributor Author

lishaduck commented Sep 3, 2025

@rrousselGit I think this works now! 🤞🏻
EDIT: WHOOO! 🎉

If so, I'll try to follow up with build v4/source_gen v4/analyzer 8 upgrade shortly after merge.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
benchmarks/pubspec.yaml (1)

19-20: Missing version for build_runner will break pub get.

build_runner: has no version/spec. Pubspec entries can’t be null; this will fail resolution. Pin a version (align with other packages) or remove it if unused.

Apply one of these:

 dev_dependencies:
   freezed: ^3.0.2
   json_serializable: ^6.1.3
-  build_runner:
+  build_runner: ^2.4.11

Or remove if unneeded:

 dev_dependencies:
   freezed: ^3.0.2
   json_serializable: ^6.1.3
-  build_runner:
🧹 Nitpick comments (7)
packages/freezed_lint/example/analysis_options.yaml (1)

11-15: Scoped ignores OK; prefer local pragma where feasible.

These “expected errors” ignores are fine for examples. If any of these are tied to specific fixtures, consider replacing them with file-level // ignore_for_file: pragmas to avoid masking unrelated regressions.

packages/freezed/build.yaml (1)

14-15: Redundant include pattern.

test/**/* already covers test/*. You can drop the single-level pattern to simplify.

           include:
-            - test/*
             - test/**/*
.github/workflows/build.yml (3)

35-37: Nice: unified working-directory.

With defaults.run.working-directory set, you can remove per-step working-directory overrides below.

-      - name: Analyze
-        run: flutter analyze --fatal-infos
-        working-directory: ${{ matrix.package }}
+      - name: Analyze
+        run: flutter analyze --fatal-infos
-      - name: Run tests
-        run: |
+      - name: Run tests
+        run: |
           if grep -q "flutter_test:" "pubspec.yaml"; then
             flutter test
           elif grep -q "test:" "pubspec.yaml"; then
             dart test
           fi
-        working-directory: ${{ matrix.package }}

45-45: Cache on both channels (or stable) for speed.

Caching only on master likely slows stable runs. Consider caching on both channels, or at least on stable where most contributors run locally.

-          cache: ${{ matrix.channel == 'master' }}
+          cache: true

66-70: Anchor grep for test detection to reduce false positives.

Anchor to line starts to avoid matching commented lines or keys like integration_test: etc.

-          if grep -q "flutter_test:" "pubspec.yaml"; then
+          if grep -Eq '^\s*flutter_test\s*:' pubspec.yaml; then
             flutter test
-          elif grep -q "test:" "pubspec.yaml"; then
+          elif grep -Eq '^\s*test\s*:' pubspec.yaml; then
             dart test
           fi
packages/freezed/example/lib/non_diagnosticable.freezed.dart (2)

16-35: Potentially misleading base mixin equality.

The mixin _$Example defines operator == that only checks runtimeType, ignoring fields. It’s harmless if every concrete implementation overrides equality (as done below), but it can be confusing. Consider omitting operator == from the base mixin in future generator versions.

Please confirm no types mix in _$Example without providing their own equality.


840-864: Language features: abstract mixin class with factory.

This pattern requires modern Dart. Ensure all packages in the melos workspace have aligned SDK constraints and CI uses a matching Dart/Flutter toolchain.

If CI is flaky locally, verify toolchain versions used by melos/bootstrap vs CI matrix and pin them in the workflow.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 63f3366 and 3b019a3.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (30)
  • .github/workflows/build.yml (1 hunks)
  • .gitignore (1 hunks)
  • benchmarks/.gitignore (0 hunks)
  • benchmarks/lib/src/copy_with.dart (1 hunks)
  • benchmarks/lib/src/copy_with.freezed.dart (1 hunks)
  • benchmarks/lib/src/equal.freezed.dart (1 hunks)
  • benchmarks/pubspec.yaml (1 hunks)
  • packages/freezed/.gitignore (0 hunks)
  • packages/freezed/build.yaml (1 hunks)
  • packages/freezed/example/.gitignore (0 hunks)
  • packages/freezed/example/lib/diagnosticable.freezed.dart (1 hunks)
  • packages/freezed/example/lib/equals.freezed.dart (1 hunks)
  • packages/freezed/example/lib/main.freezed.dart (1 hunks)
  • packages/freezed/example/lib/main.g.dart (1 hunks)
  • packages/freezed/example/lib/non_diagnosticable.freezed.dart (1 hunks)
  • packages/freezed/example/lib/time_slot.freezed.dart (1 hunks)
  • packages/freezed/example/pubspec.yaml (1 hunks)
  • packages/freezed/pubspec.yaml (1 hunks)
  • packages/freezed_annotation/.gitignore (0 hunks)
  • packages/freezed_annotation/pubspec.yaml (1 hunks)
  • packages/freezed_lint/.gitignore (1 hunks)
  • packages/freezed_lint/example/analysis_options.yaml (1 hunks)
  • packages/freezed_lint/example/lib/missing_mixin.freezed.dart (0 hunks)
  • packages/freezed_lint/example/pubspec.yaml (1 hunks)
  • packages/freezed_lint/lib/src/missing_mixin.dart (1 hunks)
  • packages/freezed_lint/lib/src/missing_private_empty_ctor.dart (1 hunks)
  • packages/freezed_lint/pubspec.yaml (1 hunks)
  • packages/freezed_lint/pubspec_overrides.yaml (0 hunks)
  • pubspec.yaml (1 hunks)
  • pubspec_overrides.yaml (1 hunks)
💤 Files with no reviewable changes (6)
  • packages/freezed/.gitignore
  • packages/freezed_lint/pubspec_overrides.yaml
  • benchmarks/.gitignore
  • packages/freezed/example/.gitignore
  • packages/freezed_lint/example/lib/missing_mixin.freezed.dart
  • packages/freezed_annotation/.gitignore
✅ Files skipped from review due to trivial changes (1)
  • packages/freezed/example/lib/equals.freezed.dart
🚧 Files skipped from review as they are similar to previous changes (15)
  • packages/freezed_lint/lib/src/missing_mixin.dart
  • pubspec.yaml
  • packages/freezed/example/pubspec.yaml
  • packages/freezed_lint/example/pubspec.yaml
  • packages/freezed/example/lib/main.g.dart
  • .gitignore
  • benchmarks/lib/src/copy_with.dart
  • packages/freezed_lint/.gitignore
  • benchmarks/lib/src/equal.freezed.dart
  • benchmarks/lib/src/copy_with.freezed.dart
  • packages/freezed_annotation/pubspec.yaml
  • packages/freezed_lint/lib/src/missing_private_empty_ctor.dart
  • packages/freezed/example/lib/main.freezed.dart
  • packages/freezed_lint/pubspec.yaml
  • pubspec_overrides.yaml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-01-07T20:51:22.701Z
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.

Applied to files:

  • packages/freezed_lint/example/analysis_options.yaml
  • benchmarks/pubspec.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: freezed (packages/freezed_annotation, stable, get)
  • GitHub Check: freezed (packages/freezed/example, stable, downgrade)
  • GitHub Check: freezed (packages/freezed/example, stable, get)
  • GitHub Check: freezed (packages/freezed, master, get)
  • GitHub Check: freezed (packages/freezed, stable, get)
  • GitHub Check: freezed (packages/freezed, stable, downgrade)
🔇 Additional comments (21)
packages/freezed/pubspec.yaml (2)

11-11: Confirm workspace resolution behavior and SDK alignment.

Adding resolution: workspace is correct for Pub Workspaces. Please confirm the root workspace includes this package and that CI’s stable SDK version is >= 3.8.0 so workspace resolution and the package’s SDK constraint don’t conflict.


19-22: Version bumps look good; verify transitive compatibility.

The updates to source_gen/json_annotation/dart_style look consistent with analyzer (>=7.5.9 <8.0.0). Run a quick dart pub get && dart pub outdated --resolution=workspace in this package to ensure no hidden conflicts.

benchmarks/pubspec.yaml (3)

6-9: Workspace enablement looks right; ensure it resolves to local packages.

With resolution: workspace, freezed and freezed_annotation should resolve to local workspace versions that satisfy your constraints. Please confirm dart pub get in benchmarks uses the workspace copies (not hosted).


13-14: Dependency ranges are compatible with workspace versions.

freezed_annotation: ^3.0.0 and json_annotation: ^4.9.0 look fine given the workspace. No changes needed.


17-17: Dev dependency range acceptable.

freezed: ^3.0.2 will resolve to the workspace’s 3.2.x. No action required.

packages/freezed/build.yaml (1)

3-6: Good: exclude example at the target level.

Moving example/* exclusion to $default.sources is cleaner and avoids per-builder redundancy.

.github/workflows/build.yml (1)

32-34: Clarify downgrade intent.

Current matrix excludes channel: master with dependencies: downgrade, so downgrade runs only on stable. Confirm that’s intentional; earlier workflows often exercised downgrade on master (nightly) to catch forward-compat issues.

packages/freezed/example/lib/time_slot.freezed.dart (9)

1-6: Generated file header looks correct.

Standard ignore annotations and coverage exclusion are appropriate for generated code. Nothing to change here.


16-24: Public API surface (start/end, copyWith) looks consistent with Freezed output.

Nullable TimeOfDay getters and the eager copyWith getter are fine. No action.


28-35: Equality/hashCode implementations LGTM.

Relies on TimeOfDay’s value equality; Object.hash is appropriate.


80-86: _TimeSlot implementation matches the declared API.

Constructor and final fields look correct.


90-93: copyWith override on _TimeSlot is consistent.

Returns the specialized _$TimeSlotCopyWith; inlining hints are fine.


96-103: Equality/hashCode for _TimeSlot LGTM.

Matches the mixin behavior; no divergence.


134-140: copyWith call path is correct.

Sentinel handling and casting to TimeOfDay? are as expected.


66-72: No action needed – freezed_annotation import and part directive are present in time_slot.dart.


45-51: Dart SDK constraints confirmed
All pubspec.yaml files specify a minimum SDK ≥3.5.0 (Dart 3+), so the abstract mixin class syntax is supported and no changes are required.

packages/freezed/example/lib/diagnosticable.freezed.dart (2)

54-63: Good: diagnostics are applied on the concrete type.

extends Example with DiagnosticableTreeMixin is the right pattern; once the two “implements” above are removed, this will continue to work as intended (DiagnosticableTreeMixin will call the debugFillProperties defined in the mixin).

Please run dart analyze to confirm there are no remaining missing-implementation warnings for DiagnosticableTree/Diagnosticable.


114-120: The script will verify your SDK constraints and inspect any DiagnosticableTreeMixin or mixin/factory usages. Please review the output and confirm that:

  • Every pubspec.yaml’s environment.sdk is set to at least “>=3.0.0” (or your minimum required Dart version).
  • No mixin improperly implements DiagnosticableTreeMixin.
  • The generated example code’s mixin/factory patterns align with your SDK’s language feature support.
packages/freezed/example/lib/non_diagnosticable.freezed.dart (3)

48-76: Concrete equality/hash for _Example looks correct.

Field-wise equality with Object.hash is fine here.


130-142: Deep equality on generic field c is appropriate.

Using DeepCollectionEquality for T handles list/map/set payloads. Looks good.


971-999: Ensure House mixin is declared or imported
No House definition was found under packages/freezed/example/lib; add or import its declaration to avoid missing‐symbol errors (note: GeographicArea is already defined).

Comment on lines +56 to 59
if: matrix.package != 'packages/freezed_lint/example'
continue-on-error: true
run: dart run build_runner build --delete-conflicting-outputs

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Gate codegen on dependency; drop continue-on-error.

Instead of relying on continue-on-error, conditionally run build_runner only when declared. This avoids masking real failures on packages that should generate code.

-      - name: Generate
-        if: matrix.package != 'packages/freezed_lint/example'
-        continue-on-error: true
-        run: dart run build_runner build --delete-conflicting-outputs
+      - name: Generate
+        if: matrix.package != 'packages/freezed_lint/example'
+        run: |
+          if grep -Eq '^\s*build_runner\s*:' pubspec.yaml; then
+            dart run build_runner build --delete-conflicting-outputs
+          else
+            echo "Skipping build_runner (no dependency found)"
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if: matrix.package != 'packages/freezed_lint/example'
continue-on-error: true
run: dart run build_runner build --delete-conflicting-outputs
- name: Generate
if: matrix.package != 'packages/freezed_lint/example'
run: |
if grep -Eq '^\s*build_runner\s*:' pubspec.yaml; then
dart run build_runner build --delete-conflicting-outputs
else
echo "Skipping build_runner (no dependency found)"
fi
🤖 Prompt for AI Agents
In .github/workflows/build.yml lines 56-59, the step currently uses a simple
matrix.package check and continue-on-error to avoid failing runs; instead remove
continue-on-error and gate the run with an explicit condition that only selects
packages that declare codegen (e.g., detect packages that list
build_runner/build_* in dev_dependencies or include a build.yaml) — implement
this by adding a prior job/step that scans package/pubspec.yaml files and emits
an output (a list or map) of packages requiring codegen, then change the step's
if to check membership (for example using
contains(needs.scan.outputs.packages_with_codegen, matrix.package)) and keep
run: dart run build_runner build --delete-conflicting-outputs so failures
surface for packages that should generate code.

Comment on lines +16 to +26
mixin _$Example<T> implements DiagnosticableTreeMixin {

dynamic get theAnswer;


@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'Example<$T>'))
..add(DiagnosticsProperty('theAnswer', theAnswer));
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Don't “implements DiagnosticableTreeMixin” on a Freezed mixin; use it on concrete classes only.

Using implements on a mixin forces you to re-implement the entire DiagnosticableTree/Diagnosticable interface surface (e.g., toDiagnosticsNode, toStringShort), not just debugFillProperties. This is likely to trip analyzer errors and is unnecessary since concrete variants already mix in DiagnosticableTreeMixin.

Suggested fix: drop the implements here and keep DiagnosticableTreeMixin on the concrete classes.

-mixin _$Example<T> implements DiagnosticableTreeMixin {
+mixin _$Example<T> {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mixin _$Example<T> implements DiagnosticableTreeMixin {
dynamic get theAnswer;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'Example<$T>'))
..add(DiagnosticsProperty('theAnswer', theAnswer));
}
mixin _$Example<T> {
dynamic get theAnswer;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'Example<$T>'))
..add(DiagnosticsProperty('theAnswer', theAnswer));
}
}
🤖 Prompt for AI Agents
In packages/freezed/example/lib/diagnosticable.freezed.dart around lines 16 to
26, the generated mixin currently declares "implements DiagnosticableTreeMixin",
which forces re-implementing Diagnosticable/DiagnosticableTree API on the mixin;
remove the "implements DiagnosticableTreeMixin" clause from the _$Example<T>
mixin so it is a plain mixin, and ensure the concrete classes (the
sealed/variant classes) continue to mix in DiagnosticableTreeMixin (or are left
unchanged) so only concrete classes carry the Diagnosticable behavior.

Comment on lines +198 to +208
mixin _$ConcreteExample<T> implements DiagnosticableTreeMixin {




@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'ConcreteExample<$T>'))
;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Same issue: remove implements DiagnosticableTreeMixin from this mixin.

Keep diagnostics on the concrete _ConcreteExample (which already has “with DiagnosticableTreeMixin”). The mixin itself shouldn’t implement the interface.

-mixin _$ConcreteExample<T> implements DiagnosticableTreeMixin {
+mixin _$ConcreteExample<T> {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mixin _$ConcreteExample<T> implements DiagnosticableTreeMixin {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'ConcreteExample<$T>'))
;
}
mixin _$ConcreteExample<T> {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties
..add(DiagnosticsProperty('type', 'ConcreteExample<$T>'))
;
}
🤖 Prompt for AI Agents
In packages/freezed/example/lib/diagnosticable.freezed.dart around lines 198 to
208, the mixin _$ConcreteExample<T> incorrectly declares "implements
DiagnosticableTreeMixin"; remove that implements clause from the mixin
declaration so the mixin does not implement DiagnosticableTreeMixin (leave the
concrete _ConcreteExample<T> class to keep "with DiagnosticableTreeMixin"), and
ensure debugFillProperties remains available on the concrete class without
changing its body.

working-directory: ${{ matrix.package }}
if: matrix.package != 'packages/freezed_lint/example'
continue-on-error: true
run: dart run build_runner build --delete-conflicting-outputs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run: dart run build_runner build --delete-conflicting-outputs
run: dart run build_runner build

I believe that flag is now deprecated, but I'm also coming back to dart after a hiatus, so maybe I'm wrong about that.

@lishaduck lishaduck mentioned this pull request Sep 3, 2025
lishaduck and others added 6 commits September 9, 2025 10:18
This is what Riverpod does, so it's probably fine?
It also makes it easier to browse the code on GitHub.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/build.yml (1)

56-58: Gate codegen; don’t mask failures with continue-on-error.

Only run build_runner where declared (or build.yaml exists) and fail if it breaks. This mirrors the earlier suggestion.

-      - name: Generate
-        if: matrix.package != 'packages/freezed_lint/example'
-        continue-on-error: true
-        run: dart run build_runner build --delete-conflicting-outputs
+      - name: Generate
+        if: matrix.package != 'packages/freezed_lint/example'
+        run: |
+          if grep -Eq '^\s*build_runner\s*:' pubspec.yaml || test -f build.yaml; then
+            dart run build_runner build --delete-conflicting-outputs
+          else
+            echo "Skipping build_runner (no dependency/build.yaml)"
+          fi
🧹 Nitpick comments (11)
packages/freezed_lint/example/analysis_options.yaml (2)

11-15: Scope down unused_element ignore to specific files

Global ignore in the example can hide accidental dead code. Keep the other expected-error ignores, but move unused_element to per-file via // ignore_for_file to retain signal.

Apply this diff here:

-    unused_element: ignore

Then, in the specific example files that intentionally define unused symbols, add at the top (outside this diff’s scope):

// ignore_for_file: unused_element

11-11: Make the intent explicit for future maintainers

Tighten the comment so folks don’t “fix” these on autopilot.

-    # Expected errors
+    # Expected errors in this example package to exercise freezed_lint rules
.github/workflows/build.yml (7)

35-37: Drop redundant working-directory overrides.

defaults.run sets working-directory; per-step working-directory is unnecessary here.

-      - name: Analyze
-        run: flutter analyze --fatal-infos
-        working-directory: ${{ matrix.package }}
+      - name: Analyze
+        run: flutter analyze --fatal-infos

-      - name: Run tests
+      - name: Run tests
         run: |
           if grep -q "flutter_test:" "pubspec.yaml"; then
             flutter test
           elif grep -q "test:" "pubspec.yaml"; then
             dart test
           fi
-        working-directory: ${{ matrix.package }}

Also applies to: 62-62, 71-71


45-45: Enable cache for all channels (faster CI).

No downside to caching on stable too; key already includes channel.

-          cache: ${{ matrix.channel == 'master' }}
+          cache: true

61-61: Use dart analyze for non-Flutter packages.

Saves startup time; still fatal-infos.

-      - name: Analyze
-        run: flutter analyze --fatal-infos
+      - name: Analyze
+        run: |
+          if grep -Eq '^\s*sdk\s*:\s*flutter' pubspec.yaml; then
+            flutter analyze --fatal-infos
+          else
+            dart analyze --fatal-infos
+          fi

66-70: Harden test detection with anchored matches.

Avoid false positives from comments/strings.

-          if grep -q "flutter_test:" "pubspec.yaml"; then
+          if grep -Eq '^\s*flutter_test\s*:' pubspec.yaml; then
             flutter test
-          elif grep -q "test:" "pubspec.yaml"; then
+          elif grep -Eq '^\s*test\s*:' pubspec.yaml; then
             dart test

19-19: Normalize package paths.

Minor: benchmarks/ has a trailing slash while others don’t; pick one style.

-          - benchmarks/
+          - benchmarks
-          - packages/freezed_lint/example
+          - packages/freezed_lint/example

Also applies to: 24-24


3-11: Optional: add concurrency to cancel superseded runs.

Speeds iteration on PRs.

 name: Build
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.package }}-${{ matrix.channel }}-${{ matrix.dependencies }}
+  cancel-in-progress: true

39-46: Pin minimal permissions for Actions.

Tighten token scope.

 jobs:
   freezed:
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
packages/freezed/example/lib/main.freezed.dart (2)

221-224: Make $UnionCopyWith abstract to avoid accidental construction.

This type is used as an interface. Marking it abstract clarifies intent and prevents instantiation.

- class $UnionCopyWith<$Res>  {
+ abstract class $UnionCopyWith<$Res>  {
   $UnionCopyWith(Union _, $Res Function(Union) __);
 }

251-269: Align Data’s diagnostics/toString with other variants.

Other variants use Union.loading, Union.error, Union.complex. Data currently reports Union/Union(...). Consider making it consistent.

   void debugFillProperties(DiagnosticPropertiesBuilder properties) {
     properties
-      ..add(DiagnosticsProperty('type', 'Union'))
+      ..add(DiagnosticsProperty('type', 'Union.data'))
       ..add(DiagnosticsProperty('value', value));
   }
 ...
   @override
   String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
-    return 'Union(value: $value)';
+    return 'Union.data(value: $value)';
   }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c253daa and a7ee005.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (32)
  • .gitattributes (1 hunks)
  • .github/workflows/build.yml (1 hunks)
  • .gitignore (1 hunks)
  • benchmarks/.gitignore (0 hunks)
  • benchmarks/lib/src/copy_with.dart (1 hunks)
  • benchmarks/lib/src/copy_with.freezed.dart (1 hunks)
  • benchmarks/lib/src/equal.freezed.dart (1 hunks)
  • benchmarks/pubspec.yaml (1 hunks)
  • packages/freezed/.gitignore (0 hunks)
  • packages/freezed/build.yaml (1 hunks)
  • packages/freezed/example/.gitignore (0 hunks)
  • packages/freezed/example/lib/diagnosticable.freezed.dart (1 hunks)
  • packages/freezed/example/lib/equals.freezed.dart (1 hunks)
  • packages/freezed/example/lib/main.freezed.dart (1 hunks)
  • packages/freezed/example/lib/main.g.dart (1 hunks)
  • packages/freezed/example/lib/non_diagnosticable.freezed.dart (1 hunks)
  • packages/freezed/example/lib/time_slot.freezed.dart (1 hunks)
  • packages/freezed/example/pubspec.yaml (1 hunks)
  • packages/freezed/pubspec.yaml (1 hunks)
  • packages/freezed_annotation/.gitignore (0 hunks)
  • packages/freezed_annotation/pubspec.yaml (1 hunks)
  • packages/freezed_annotation/pubspec_overrides.yaml (0 hunks)
  • packages/freezed_lint/.gitignore (1 hunks)
  • packages/freezed_lint/example/analysis_options.yaml (1 hunks)
  • packages/freezed_lint/example/lib/missing_mixin.freezed.dart (0 hunks)
  • packages/freezed_lint/example/pubspec.yaml (1 hunks)
  • packages/freezed_lint/lib/src/missing_mixin.dart (1 hunks)
  • packages/freezed_lint/lib/src/missing_private_empty_ctor.dart (1 hunks)
  • packages/freezed_lint/pubspec.yaml (1 hunks)
  • packages/freezed_lint/pubspec_overrides.yaml (0 hunks)
  • pubspec.yaml (1 hunks)
  • pubspec_overrides.yaml (1 hunks)
💤 Files with no reviewable changes (7)
  • packages/freezed_annotation/pubspec_overrides.yaml
  • packages/freezed_lint/example/lib/missing_mixin.freezed.dart
  • packages/freezed/example/.gitignore
  • packages/freezed_annotation/.gitignore
  • benchmarks/.gitignore
  • packages/freezed_lint/pubspec_overrides.yaml
  • packages/freezed/.gitignore
✅ Files skipped from review due to trivial changes (5)
  • packages/freezed_lint/lib/src/missing_mixin.dart
  • packages/freezed_lint/lib/src/missing_private_empty_ctor.dart
  • benchmarks/lib/src/copy_with.dart
  • packages/freezed/example/lib/main.g.dart
  • .gitattributes
🚧 Files skipped from review as they are similar to previous changes (17)
  • benchmarks/lib/src/copy_with.freezed.dart
  • benchmarks/lib/src/equal.freezed.dart
  • packages/freezed_lint/example/pubspec.yaml
  • benchmarks/pubspec.yaml
  • .gitignore
  • pubspec.yaml
  • packages/freezed/example/pubspec.yaml
  • packages/freezed/build.yaml
  • pubspec_overrides.yaml
  • packages/freezed/example/lib/equals.freezed.dart
  • packages/freezed/example/lib/time_slot.freezed.dart
  • packages/freezed_annotation/pubspec.yaml
  • packages/freezed/example/lib/non_diagnosticable.freezed.dart
  • packages/freezed/example/lib/diagnosticable.freezed.dart
  • packages/freezed/pubspec.yaml
  • packages/freezed_lint/pubspec.yaml
  • packages/freezed_lint/.gitignore
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-01-07T20:51:22.701Z
Learnt from: lishaduck
PR: rrousselGit/freezed#1147
File: packages/freezed_lint/pubspec.yaml:12-12
Timestamp: 2025-01-07T20:51:22.701Z
Learning: The analyzer version update to >=7.0.0 in freezed_lint package is blocked by invertase/dart_custom_lint#300, preventing alignment with freezed package's analyzer requirements.

Applied to files:

  • packages/freezed_lint/example/analysis_options.yaml
🔇 Additional comments (6)
packages/freezed_lint/example/analysis_options.yaml (1)

17-17: Plugin activation scope is correct
custom_lint is only enabled in packages/freezed_lint/example/analysis_options.yaml and is not enabled at the workspace or root level.

.github/workflows/build.yml (1)

58-58: Confirm --delete-conflicting-outputs flag support
Manually run dart run build_runner build --help (with the version locked in pubspec.lock) to ensure --delete-conflicting-outputs is still recognized—if it’s been deprecated, remove it; otherwise leave it in place.
.github/workflows/build.yml:58

packages/freezed/example/lib/main.freezed.dart (4)

157-186: Robust union JSON dispatch.

Switching on json['custom-key'] with a clear CheckedFromJsonException fallback looks good.


306-346: Loading variant serialization and diagnostics look correct.


433-476: Complex variant: fields, copyWith, JSON all consistent.


51-52: SDK constraints and generated parts verified
All packages enforce Dart 3+ and example/lib/main.dart correctly includes part 'main.freezed.dart' and part 'main.g.dart' with the generated files present.

@lishaduck
Copy link
Contributor Author

Ok, yay, hit the flutter_test doesn't work with Analyzer 8 again. Back to draft...

@lishaduck lishaduck marked this pull request as draft September 9, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants